package net.vkits.api;

import io.jsonwebtoken.Claims;
import net.vkits.anjiamiao.application.OrderApplicationService;
import net.vkits.common.dto.Order;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;


@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringCodegen", date = "2016-10-27T05:49:23.577Z")

@Controller
public class OrdersApiController implements OrdersApi {

    @Resource
    private HttpServletRequest request;
    @Resource
    private OrderApplicationService orderApplicationService;

    public ResponseEntity<List<Order>> ordersGet() {
        final Claims claims = (Claims) request.getAttribute("claims");
        String cellphone = claims.get("phone").toString();

        List<Order> orderList = orderApplicationService.getOrderList(cellphone);

        return new ResponseEntity<>(orderList, HttpStatus.OK);
    }

}
